﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VICC_WFEVENTSCLASS
    {
    
                 public string MANDANT { get { if (dwMaster == null) return ""; return dwMaster["MANDANT"].ToString(); } set { if (dwMaster == null) return; dwMaster["MANDANT"] = value; OnPropertyChanged("MANDANT", value); } } //lENGth 2
                 public string ROWNID { get { if (dwMaster == null) return ""; return dwMaster["ROWNID"].ToString(); } set { if (dwMaster == null) return; dwMaster["ROWNID"] = value; OnPropertyChanged("ROWNID", value); } } //lENGth 20
                 public string WFCLASS { get { if (dwMaster == null) return ""; return dwMaster["WFCLASS"].ToString(); } set { if (dwMaster == null) return; dwMaster["WFCLASS"] = value; OnPropertyChanged("WFCLASS", value); } } //lENGth 3
                 public string WFCDES { get { if (dwMaster == null) return ""; return dwMaster["WFCDES"].ToString(); } set { if (dwMaster == null) return; dwMaster["WFCDES"] = value; OnPropertyChanged("WFCDES", value); } } //lENGth 40
                 public string NEWUSER { get { if (dwMaster == null) return ""; return dwMaster["NEWUSER"].ToString(); } set { if (dwMaster == null) return; dwMaster["NEWUSER"] = value; OnPropertyChanged("NEWUSER", value); } } //lENGth 8
                 public string NEWTIME { get { if (dwMaster == null) return ""; return dwMaster["NEWTIME"].ToString(); } set { if (dwMaster == null) return; dwMaster["NEWTIME"] = value; OnPropertyChanged("NEWTIME", value); } } //lENGth 20
                 public string CHGUSER { get { if (dwMaster == null) return ""; return dwMaster["CHGUSER"].ToString(); } set { if (dwMaster == null) return; dwMaster["CHGUSER"] = value; OnPropertyChanged("CHGUSER", value); } } //lENGth 8
                 public string CHGTIME { get { if (dwMaster == null) return ""; return dwMaster["CHGTIME"].ToString(); } set { if (dwMaster == null) return; dwMaster["CHGTIME"] = value; OnPropertyChanged("CHGTIME", value); } } //lENGth 20
        
    }
    public partial class VICC_WFEVENTSCLASS
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                default:
                    #region=========
                    dwReturn["MANDANT"] = "00";
                    dwReturn["ROWNID"] = INTEXDBC.GetSeq();
                    dwReturn["WFCLASS"] = "901";
                    dwReturn["WFCDES"] = "                                        ";
                    dwReturn["NEWUSER"] = app.User;
                    dwReturn["NEWTIME"] = date;
                    dwReturn["CHGUSER"] = "        ";
                    dwReturn["CHGTIME"] = "        ";
                    #endregion
                    break;
            }
        }


        public void InsertICC_WFEVENTSCLASS(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();
            dwData["NEWUSER"] = app.User;
            dwData["NEWTIME"] = date;
            or1.CommandText = "INSERT INTO ICC_WFEVENTSCLASS(MANDANT,ROWNID,WFCLASS,WFCDES,NEWUSER,NEWTIME,CHGUSER,CHGTIME)"
                                + " VALUES (:MANDANT:,:ROWNID:,:WFCLASS:,:WFCDES:,:NEWUSER:,:NEWTIME:,:CHGUSER:,:CHGTIME:)";

            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }

        public DataSet QueryICC_WFEVENTSCLASS(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:   SResult = QWFC01(dwData);  break;
                case 4: SResult = QWFC04(dwData); break; 
                default: case 9999: SResult = QWFCALL(dwData); break;
            }
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QWFC01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand(); 
            or1.CommandText = "SELECT * FROM ICC_WFEVENTSCLASS WHERE  ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QWFC04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ICC_WFEVENTSCLASS WHERE  MANDANT=:MANDANT:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QWFCALL(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT WFCLASS AS KEY,WFCDES AS DES,M.* FROM ICC_WFEVENTSCLASS M";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DeleteICC_WFEVENTSCLASS(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM ICC_WFEVENTSCLASS WHERE  ROWNID=:ROWNID:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public void UpdateICC_WFEVENTSCLASS(DataRow dwData, int option = 1)
        {
            dwData["CHGUSER"] = app.User;
            dwData["CHGTIME"] = date;
            or1 = OracleDB.CreateCommand();
            #region====Command====
            or1.CommandText = "UPDATE ICC_WFEVENTSCLASS SET MANDANT=:MANDANT:, WFCLASS=:WFCLASS:, WFCDES=:WFCDES:, NEWUSER=:NEWUSER:, NEWTIME=:NEWTIME:, CHGUSER=:CHGUSER:, CHGTIME=:CHGTIME: "
                + " WHERE ROWNID=:ROWNID: ";
            #endregion
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
